//
// Created by talentestors on 2024/1/21.
//
#include <iostream>

using std::cout;

class Stone {
private:
    enum {Lbs_per_stn = 14};    // pounds per stone
    int stone;                  // whole stones
    double pds_left;            // fractional pounds
    double pounds;              // entire weight in pounds
public:
    // construct from double pounds
    explicit Stone(double lbs) {
        stone = int(lbs) / Lbs_per_stn;    // integer division
        pds_left = int(lbs) % Lbs_per_stn + lbs - int(lbs);
        pounds = lbs;
    }

    // constructor from stone, lbs
    Stone(int stn, double lbs) {
        stone = stn;
        pds_left = lbs;
        pounds = stn * Lbs_per_stn + lbs;
    }

    // default constructor, wt = 0
    Stone() = default;

    // destructor
    ~Stone() = default;

    // show weight in stones
    void show_stn() const {
        cout << stone << " stone, " << pds_left << " pounds\n";
    }

    // show weight in pounds
    void show_lbs() const {
        cout << pounds << " pounds\n";
    }

    // conversion functions
    explicit operator int() const {
        return int(pounds + 0.5);
    }

    operator double() const {
        return pounds;
    }
};

int main() {
    using std::cout;
    Stone poppins(9, 2.8);  // 9 stone, 2.8 pounds
    double p_wt = poppins;  // implicit conversion
    cout << "Convert to double => ";
    cout << "Poppins: " << p_wt << " pounds.\n";
    cout << "Convert to int => ";
    cout << "Poppins: " << int(poppins) << " pounds.\n";
    return 0;
}
